const path = require('path')
const webpack = require('webpack')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')

module.exports = {
  //  全局变量 shiming exports 放开
  /* entry: {
   app: './src/index.js',
   test: './src/test.js',
  }, */
  entry:{
    polyfills: './src/polyfills.js',
    index: './src/index.js'
  },
  output:{
    filename:'[name].[chunkhash].js',
    path:path.resolve(__dirname,'dist')
  },
  plugins:[
    new HtmlWebpackPlugin({
      title:'shimming'
    }),
    new CleanWebpackPlugin(),
    //自动加载模块
    /* 如果你遇到了至少一处用到 lodash 变量的模块实例，
    那请你将 lodash package 包引入进来，
    并将其提供给需要用到的其他的模块。 */
    new webpack.ProvidePlugin({
      _:'loadsh',
      $:'jquery',
        // 调用 单个方法
      join:['lodash','join']
    })
  ],
  module:{
    rules:[
      {
       test: require.resolve('./src/globals.js'),
       use: 'exports-loader?file,parse=helpers.parse'
      }
    ]
  }
}